const express = require('express')
const router = express.Router()

router.post('/user/login', (req, res) => {
  const account = req.body.account
  const password = req.body.password
  let data
  if (account === 'admin' && password === '123456') {
    data = {
      code: 200,
      data: {
        userId: '1',
        token:
          'eyJhbGciOiJIUzUxMiJ9.eyJ1c2VySWQiOiJhZG1pbiIsInVzZXJOYW1lIjoiYWRtaW4iLCJvcmdDb2RlIjoiMzUwMDAiLCJkZXB0Q29kZSI6IjM1MDAwIiwiYXVkIjoiYWRtaW4iLCJpc3MiOiJhZG1pbiIsImV4cCI6MTU5MzUzNTU5OH0.0pJAojRtT5lx6PS2gH_Q9BmBxeNlgBL37ABX22HyDlebbr66cCjVYZ0v0zbLO_9241FX9-FZpCkEqE98MQOyWw'
      },
      msg: '登录成功'
    }
  } else if (account === 'user' && password === '123456') {
    data = {
      code: 200,
      data: {
        userId: '2',
        token:
          'eyJhbGciOiJIUzUxMiJ9.eyJ1c2VySWQiOiJhZG1pbiIsInVzZXJOYW1lIjoiYWRtaW4iLCJvcmdDb2RlIjoiMzUwMDAiLCJkZXB0Q29kZSI6IjM1MDAwIiwiYXVkIjoiYWRtaW4iLCJpc3MiOiJhZG1pbiIsImV4cCI6MTU5MzUzNTU5OH0.0pJAojRtT5lx6PS2gH_Q9BmBxeNlgBL37ABX22HyDlebbr66cCjVYZ0v0zbLO_9241FX9-FZpCkEqE98MQOy'
      },
      msg: '登录成功'
    }
  }
  setTimeout(() => {
    res.json(data)
  }, 1500)
})

module.exports = router
